package cn.tedu.boot52.controller;

import cn.tedu.boot52.entity.Hero;
import cn.tedu.boot52.mapper.HeroMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class HeroController {
    @Autowired(required = false)
    HeroMapper mapper;

    @RequestMapping("/insert")
    public void insert(@RequestBody Hero hero) {
        mapper.insert(hero);
    }
    @RequestMapping("/select")
    public List<Hero> select(){
        return mapper.select();
    }
    @RequestMapping("/delete")
    public void delete(int id){
        mapper.deleteById(id);
    }
    @RequestMapping("/selectById")
    public Hero selectById(int id){
        return mapper.selectById(id);
    }
    @RequestMapping("/update")
    public void update(@RequestBody Hero hero){
        mapper.update(hero);
    }
}
